<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : listOrder.xsl
    Created on : June 6, 2013, 9:41 PM
    Author     : TuPA
    Description:
        Purpose of transformation follows.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html"/>

    <xsl:template name="formatdate">
        <xsl:param name="datestr" />
        <xsl:variable name="mm">
            <xsl:value-of select="substring($datestr,6,2)" />
        </xsl:variable>
        <xsl:variable name="dd">
            <xsl:value-of select="substring($datestr,9,2)" />
        </xsl:variable>
        <xsl:variable name="yyyy">
            <xsl:value-of select="substring($datestr,1,4)" />
        </xsl:variable>
        <xsl:variable name="hh">
            <xsl:value-of select="substring($datestr,12,2)" />
        </xsl:variable>
        <xsl:variable name="mimi">
            <xsl:value-of select="substring($datestr,15,2)" />
        </xsl:variable>
        <xsl:variable name="ss">
            <xsl:value-of select="substring($datestr,18,2)" />
        </xsl:variable>
        <xsl:value-of select="$yyyy" />
        <xsl:value-of select="'-'" />
        <xsl:value-of select="$mm" />
        <xsl:value-of select="'-'" />
        <xsl:value-of select="$dd" />
    </xsl:template>

    <xsl:template match="MngOrders">
        <div class="onecolumn" >
            <div class="contentt"  >
                <div class="tableName">
                    <h3 id="pickMonth"></h3>
                    <table>
                        <thead>
                            <tr>
                                <th class="border">
                                    <div>ID</div>
                                </th>
                                <th class="border">
                                    <div>UserName</div>
                                </th>
                                <th class="border">
                                    <div>Fullname</div>
                                </th>
                                <th class="border">
                                    <div>Total of products</div>
                                </th>
                                <th class="border">
                                    <div>Total price of order (VND)</div>
                                </th>
                                <th class="border">
                                    <div>Date of order</div>
                                </th>
                                <th class="border">
                                    <div>Status of order</div>
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            <xsl:for-each select="MngOrder">
                                <tr>
                                    <td class="border">
                                        <a href="#" onclick="showOrderDetail({orderID})">
                                            <xsl:value-of select='orderID'/>
                                        </a>
                                    </td>
                                    <td class="border">
                                        <xsl:value-of select='Username'/>
                                    </td>
                                    <td class="border">
                                        <xsl:value-of select='Fullname'/>
                                    </td>
                                    <td class="border">
                                        <xsl:value-of select='totalQuantity'/>
                                    </td>
                                    <td class="border">
                                        <xsl:value-of select="format-number(totalPrice,'###,###,##0')"/>
                                    </td>
                                    <td class="border">
                                        <xsl:call-template name="formatdate">
                                            <xsl:with-param name="datestr" select="orderDate"/>
                                        </xsl:call-template>
                                    </td>
                                    <td class="border">
                                        <xsl:if test="(orderStatus='0')">
                                            <select name="" id="" onchange="confirmAction({orderID})">
                                                <xsl:attribute name="id">orderStatus<xsl:value-of select='orderID'/>
                                                </xsl:attribute>
                                                <option value="0" selected="selected">Keep on delivery</option>
                                                <option value="1">Delivered</option>
                                                <option value="2">Canceled</option>
                                            </select>
                                        </xsl:if>
                                        <xsl:if test="(orderStatus='1')">
                                            <select name="" disabled="" onchange="confirmAction({orderID})">
                                                <xsl:attribute name="id">orderStatus<xsl:value-of select='orderID'/>
                                                </xsl:attribute>
                                                <option value="0">Keep on delivery</option>
                                                <option value="1" selected="selected">Delivered</option>
                                                <option value="2">Canceled</option>
                                            </select>
                                        </xsl:if>
                                        <xsl:if test="(orderStatus='2')">
                                            <select name="" disabled="" onchange="confirmAction({orderID})">
                                                <xsl:attribute name="id">orderStatus<xsl:value-of select='orderID'/>
                                                </xsl:attribute>
                                                <option value="0">Keep on delivery</option>
                                                <option value="1">Delivered</option>
                                                <option value="2" selected="selected">Canceled</option>
                                            </select>
                                        </xsl:if>
                                    </td>
<!--                                    <td>
                                        <input type="submit" value="Update" name="btAction" onclick="updateStatusOrder({orderID})" />
                                    </td>-->
                                </tr>
                            </xsl:for-each>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </xsl:template>
</xsl:stylesheet>